#ifndef __INIT_FASTRTPS_LOGGRT__
#define __INIT_FASTRTPS_LOGGRT__
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/dds/log/FileConsumer.hpp>
#include <string>
#include <regex>

using namespace eprosima::fastdds::dds;

void init_fastrtps_logger()
{
    static bool init = false;

    if (!init) {
        init = true;
        std::string path = "/tmp/fastdds_log.txt";
        std::cout << "set fastdds log:" << path << std::endl;
        Log::ClearConsumers();
        std::unique_ptr<FileConsumer> file_consumer(new FileConsumer(path));
        Log::RegisterConsumer(std::move(file_consumer));
        Log::ReportFilenames(false);
        Log::ReportFunctions(false);
        Log::SetVerbosity(Log::Kind::Warning);
        // Log::SetErrorStringFilter(std::regex("(remove change)|(added with)"));
    }
}

#endif  // __INIT_FASTRTPS_LOGGRT__